<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>检索回答</title>
    <script src="../../static/js/vue.js"></script>
    <script src="../../static/js/axios.min.js"></script>
    <link rel="stylesheet" href="../../static/test/src/iconfont.css">


    <style>

        *
        {
            padding: 0;
            margin: 0;
        }
        body
        {
            background-image: url("../../static/test/img/back.png");
            display: flex;
            flex-direction: column;
        }


        .search
        {
            position: relative;
            top: 40vh;
            margin: 0 auto;
            display: flex;
            width: 600px;

        }

        body .searchBox
        {
            height: 52px;
            border-radius: 26px;
            display: flex;
            justify-content: space-between;
            background-color: #ffffff;
            font-size: 25px;
            padding-left: 26px;
            line-height: 52px;
        }

        body .searchList
        {
            height: 45px;
            display: flex;
            justify-content: space-between;
            background-color: #ffffff;
            font-size: 25px;
            padding-left: 26px;
            line-height: 45px;
        }

        .searchBox > input
        {
            width: 500px;
            border: none;
            text-decoration: none;
            border-radius: 26px;
            outline: none;
            font-size: 25px;

        }
        .searchBox > #searchIcon
        {
            font-size: 40px;
            line-height: 52px;
            margin-right: 15px;

        }
        .searchList:hover
        {
            background-color: #ececec;
        }
        .search
        {
            display: flex;
            flex-direction: column;
        }
        .searchList .searchListInfo
        {
            width:500px;
        }
        .searchList .searchListDel
        {
            width: 70px;
            margin-right: 30px;
            font-size: 15px;
        }
    </style>

</head>
<body>

<div id="sBox" class="search" >
    <div class="searchBox" :style="(hasList && isChoice)? 'border-radius: 26px 26px 0 0':'border-radius: 26px'">
        <input type="text" value="inputList" v-model="input" @focus="isChoice = true" @blur="isChoice = true">
        <span class="iconfont icon-RectangleCopy2" id="searchIcon" @click="search()"></span>
    </div>
    <ul v-if="isChoice">
        <li v-for="(data, index) in my_search" class="searchList" :key="data"
            :style="index + 1 === my_search.length? 'border-radius: 0 0 26px 26px': ''">
            <a href="" class="searchListInfo">{{ index }}{{ data }}</a>
            <div class="searchListDel">删除</div>
        </li>
    </ul>
    <form action="http://127.0.0.1:5000/search" method="post">
        <input type="text" name="question">
        <input type="submit" value="提交">
    </form>
</div>
    <script>
    let vm = new Vue
    (
        {
            el:"#sBox",
            data:
                {
                    searchList:
                        ["aaa","aab","abc","bbc","abb","cbb","dva","hjg"],
                    input:"",
                    isChoice: false,
                    hasList: false
                },
            methods:
                {
                    search()
                    {
                        let url = "http://127.0.0.1:5000/search"
                        let data = {'question': this.input}
                        axios.post(url, data, {
                          headers: {'Content-Type':'application/x-www-form-urlencoded'}
                        })
                    }

                },
            computed:
                {
                    my_search()
                    {
                        let result = this.searchList.filter(item => item.includes(this.input))
                        this.hasList = result.length !== 0
                        return result
                    }
                }

        }
    )
</script>
</body>



</html>